package zhan.redis;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

public class testRedis {
    public static void main(String[] args) throws Exception {

        ApplicationContext a = new ClassPathXmlApplicationContext("classpath:spring-context.xml");
        RedisTemplate<String, Object> redisTemplate = (RedisTemplate) a.getBean("redisTemplate");
        ValueOperations<String, Object> value = redisTemplate.opsForValue();
        value.set("name", "zhan");
        value.set("age",10);
        value.set("phone","1839239092");

        System.out.println("缓存中名称："+value.get("name"));
        System.out.println("缓存中年龄："+value.get("age"));
        System.out.println("缓存中电话："+value.get("phone"));

        //System.err.println("缓存中xingbie："+value.get("sex"));

        //System.out.println("缓存中名称："+getCache);
    }
}
